var express = require('express');
var router = express.Router();
/* GET home page. */
// router.get('/static/*',function(req,res,next){
//     console.log('请求路径:'+req._parsedUrl.path);
//     var path=req._parsedUrl.path;
//     res.sendFile('/static/14th/index.html');
//     res.end();
//     // next();
// });
router.get('/*', function(req, res, next) {
    console.log('请求地址:'+req.headers.host);
    var url=req.headers.host;
    console.log('请求路径:'+req._parsedUrl.path);
    var path=req._parsedUrl.path;
    // if(url==='39.106.37.159'){
    //     next();
    // }else if(url==='localhost'||url==='192.168.1.104'){
    //     path='static/14ch'+path;
    //     res.render(path);
    // }else
        {
        console.log(url);
        const first=url.split('.');
        switch(first[first.length-2]){
            case '14th':
                switch(first[0]){
                    case '14th':
                    case 'www':
                        path='static/14th'+path;
                        res.render(path);
                        break;
                    default:
                }
                break;
            case '14ch':
                switch(first[0]){
                    case 'comic':
                        path='static/14ch/musicdog'+path;
                        res.render(path);
                        break;
                    case '14th':
                    case 'www':
                    default:
                        path='static/14ch'+path;
                        res.render(path);
                        break;
                }
                break;
        }
    }
    next();
});
router.get('/14th/',function (req,res,next) {
    console.log('请求路径:'+req._parsedUrl.path);
    res.render('static/14th/index')
});
module.exports = router;
